package com.xiaoshuidi.cloud.module.finance.controller.admin.taxRate;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.framework.security.core.LoginUser;
import com.xiaoshuidi.cloud.framework.security.core.util.SecurityFrameworkUtils;
import com.xiaoshuidi.cloud.module.finance.controller.admin.invoice.vo.FinanceInvoiceTitleConfigReqVO;
import com.xiaoshuidi.cloud.module.finance.controller.admin.invoice.vo.FinanceInvoiceTitleConfigRespVO;
import com.xiaoshuidi.cloud.module.finance.controller.admin.taxRate.vo.FinanceTaxRateConfigReqVO;
import com.xiaoshuidi.cloud.module.finance.controller.admin.taxRate.vo.FinanceTaxRateConfigRespVO;
import com.xiaoshuidi.cloud.module.finance.controller.admin.taxRate.vo.InvoiceTaxRateConfigRespVO;
import com.xiaoshuidi.cloud.module.finance.service.invoice.FinanceInvoiceTitleConfigService;
import com.xiaoshuidi.cloud.module.finance.service.taxRate.FinanceTaxRateConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.validation.Valid;
import java.util.List;

@Tag(name = "运营配置 - 税率配置")
@RestController
@RequestMapping("/finance/taxRate")
@Validated
public class FinanceTaxRateConfigController {
    @Resource
    private FinanceTaxRateConfigService financeTaxRateConfigService;

    @GetMapping("/get")
    @PermitAll
    @Operation(summary = "根据门店获取税率配置")
    public CommonResult<InvoiceTaxRateConfigRespVO> get(@RequestParam("apartmentId") Long apartmentId) {
        return CommonResult.success(financeTaxRateConfigService.get(apartmentId));
    }


    @PostMapping("/save")
    @PermitAll
    @Operation(summary = "保存门店税率配置")
    public CommonResult<Boolean> save(@Valid @RequestBody FinanceTaxRateConfigReqVO financeCollectionConfigReqVO) {
        financeTaxRateConfigService.save(financeCollectionConfigReqVO);
        return CommonResult.success(true);
    }
}
